package com.gitee.zycra.union.api.dao;

import com.gitee.zycra.jdbc.common.BaseDao;
import com.gitee.zycra.jdbc.common.CommonSelector;
import com.gitee.zycra.union.api.common.model.ApiProjectGroup;
import com.gitee.zycra.union.api.common.vo.ProjectGroupVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zycra
 */
@Repository
public class ApiProjectGroupDao extends BaseDao<ApiProjectGroup> {

    @Autowired
    private CommonSelector commonSelector;

    /**
     * 添加项目组
     *
     * @param apiProjectGroup 项目组对象
     * @return 影响行数
     */
    public int insert(ApiProjectGroup apiProjectGroup) {
        return insertIntoTable(apiProjectGroup);
    }

    /**
     * 更新项目组
     *
     * @param apiProjectGroup 项目组对象
     * @return 影响行数
     */
    public int updateById(ApiProjectGroup apiProjectGroup) {
        return updateTableById(apiProjectGroup);
    }

    /**
     * 查询所有组
     *
     * @return 所有组
     */
    public List<ProjectGroupVO> selectAllGroup() {
        return commonSelector.selectByParam(getJdbcTemplate(), getSelectAllColumnSql() + " WHERE deleted = 0", ProjectGroupVO.class, null);
    }
}
